import javax.swing.*;
import javax.swing.border.LineBorder;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

/**
 * @author lys
 * 项目入口，主界面
 */
public class MainClass {
    public static void  main(String[] args) {
        JFrame lib = new JFrame("图书管理系统");
        lib.setSize(800,600);
        lib.setLocationRelativeTo(null);

        lib.setLayout(null);

        JLabel welcome = new JLabel(" 欢迎登录图书管理系统 ");
        Font font = new Font("宋体", Font.BOLD, 40);
        Font font2 = new Font("宋体", Font.BOLD, 30);
        welcome.setFont(font);
        welcome.setForeground(Color.white);
        LineBorder lineBorder = (LineBorder)BorderFactory.createLineBorder(Color.WHITE);// 创建线形边框
//        welcome.setBorder(lineBorder);

        welcome.setBounds(150,150,480,50);

        Icon img = new ImageIcon(Login.class.getResource("img/14.jpeg"));
        JLabel label = new JLabel(img);
        label.setSize(800,600);


        JButton login = new JButton("登录");
        login.setLocation(150,350);
        login.setSize(150,50);
        login.setFont(font2);
        login.addActionListener(
                new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent e) {
                        lib.setVisible(false);
                        Login.getInstance().setVisible(true);
                    }
                }
        );

        JButton register = new JButton("注册");
        register.setLocation(450,350);
        register.setSize(150,50);
        register.setFont(font2);
        register.addActionListener(
                new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent e) {
                        lib.setVisible(false);
                        Register.getInstance().setVisible(true);
                    }
                }
        );

        lib.add(welcome);
        lib.add(login);
        lib.add(register);

        lib.add(label);
        // 不可以改变窗体的大小
        //lib.setResizable(false);
        // 窗口关闭
        lib.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        lib.setVisible(true);

        login.setFocusPainted(false);
        register.setFocusPainted(false);
    }
}
